package com.gtmonitor;
 
import android.app.Activity;
import android.content.res.Configuration;
import android.util.DisplayMetrics;

public class CompatPanel {
    
    private final static String TAG = "GTmonitor";
    private static int screenWidth;
    private static int screenType;
    private static CompatPanel singleton = null;
    public static DisplayMetrics metrics = new DisplayMetrics();
    
    public static CompatPanel getInstance(Activity activity)
    {
        if(singleton == null) {
            singleton = new CompatPanel(activity);
        }
        return singleton;
    }
    
    private CompatPanel(Activity activity) {
         
        activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
        
        int lanscapeHight = 0 ; 
        if( activity.getResources().getConfiguration().orientation 
                == Configuration.ORIENTATION_PORTRAIT) {
            lanscapeHight = metrics.heightPixels;
        } else {
            lanscapeHight = metrics.widthPixels;
        }
        if (lanscapeHight >= 800) {
            screenType = 2;
        } else if (lanscapeHight <= 320) {
            screenType = 0;
        } else { 
            screenType = 1;
        }
        screenWidth = metrics.widthPixels;
    }  
    
    public int getScreenWidth() {
        return screenWidth;
    }
    
    public int getScreenType() {
        return screenType;
    }
}
